import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '考核单位名称',
    dataIndex: 'orgName',
    width: 150,
    align: 'center',
  },
  {
    title: '考核单位编码',
    dataIndex: 'orgCode',
    width: 150,
    align: 'center',
  },
  {
    title: '考核单位简称',
    dataIndex: 'suitUnitName',
    width: 150,
    align: 'center',
  },
  {
    title: '上级单位',
    dataIndex: 'parentCode',
    align: 'center',
    width: 120,
    customRender: ({ text }) => {
      return -1 == text ? '无' : text;
    },
  },
  {
    title: '上级考核单位',
    dataIndex: 'parentName',
    width: 150,
    align: 'center',
  },
  {
    title: '绩效管理员',
    dataIndex: 'managerName',
    align: 'center',
    width: 90,
  },
  {
    title: '考核单位分类',
    dataIndex: 'unitType',
    customRender: ({ text }) => {
      return render.renderDict(text, 'hub_suit_type');
    },
    align: 'center',
    width: 110,
  },
  {
    title: '单位分组编码',
    dataIndex: 'stTypeCode',
    align: 'center',
    width: 110,
    ifShow: false,
  },
  {
    title: '单位分组',
    dataIndex: 'stTypeCodeName',
    align: 'center',
    width: 110,
  },
  {
    title: '是否初始化',
    dataIndex: 'isInit',
    align: 'center',
    width: 90,
    ifShow: false,
    customRender: ({ text }) => {
      // @ts-ignore
      return text ? '是' : '否';
    },
  },
  {
    title: '排序',
    dataIndex: 'displayOrder',
    align: 'center',
    width: 70,
    ifShow: false,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    align: 'center',
    width: 120,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '考核单位名称',
    field: 'suitUnitName',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '考核单位分类',
    field: 'unitType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'hub_suit_type',
      placeholder: '考核单位分类',
    },
    colProps: { span: 8 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '考核单位简称',
    field: 'suitUnitName',
    component: 'Input',
    required: true,
  },
  {
    field: 'unitType',
    label: '考核单位分类',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'hub_suit_type',
      placeholder: '考核单位分类',
      // stringToNumber: true,
    },
    required: true,
  },
  {
    label: '上级考核单位',
    field: 'parentName',
    component: 'Input',
    show: false,
  },
  {
    field: 'orgName',
    label: '绩效关联部门',
    component: 'JSelectDept',
    componentProps: { checkStrictly: true },
    required: true,
  },
  {
    label: '绩效管理员',
    field: 'managerName',
    component: 'JSelectDept',
    componentProps: { checkStrictly: true },
    required: true,
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    componentProps: {
      rows: 5,
    },
    dynamicRules: () => {
      return [
        {
          validator: (_, value) => {
            if (null != value && value.length && value.length > 500) {
              return Promise.reject('备注字数不能超过500');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
];

// 高级查询数据
export const superQuerySchema = {
  userUnit: {title: '所属单位',order: 0,view: 'text', type: 'string',},
  suitGroupCode: {title: '所属分组',order: 1,view: 'text', type: 'string',},
  suitUnitCode: {title: '单位编码',order: 2,view: 'text', type: 'string',},
  suitUnitName: {title: '考核单位名称',order: 3,view: 'text', type: 'string',},
  orgCode: {title: '组织编码',order: 4,view: 'text', type: 'string',},
  orgName: {title: '组织名称',order: 5,view: 'text', type: 'string',},
  parentCode: {title: '上级组织编码',order: 6,view: 'text', type: 'string',},
  stTypeCode: {title: '考核单位类型',order: 7,view: 'text', type: 'string',},
  remark: {title: '描述',order: 8,view: 'textarea', type: 'string',},
  manager: {title: '管理员（绩效专责）',order: 9,view: 'text', type: 'string',},
  unitType: {title: '考核单位类型 (100:省 200：地市 201：省直属 300：二级单位 301：县公司 302：新兴产业单位)',order: 10,view: 'text', type: 'string',},
  displayOrder: {title: '排序',order: 11,view: 'number', type: 'number',},
  sysCreatorId: {title: '创建人',order: 12,view: 'text', type: 'string',},
  sysCreateDate: {title: '创建日期',order: 13,view: 'datetime', type: 'string',},
  sysUpdatorId: {title: '修改人',order: 14,view: 'text', type: 'string',},
  sysUpdateDate: {title: '修改日期',order: 15,view: 'datetime', type: 'string',},
  sysDeptId: {title: '归属部门标识',order: 16,view: 'text', type: 'string',},
  sysCompanyId: {title: '归属单位标识',order: 17,view: 'text', type: 'string',},
  isInit: {title: '是否初始化',order: 18,view: 'text', type: 'string',},
  isTeamVisible: {title: '积分模式是否显示',order: 19,view: 'text', type: 'string',},
  defaultUnit: {title: '积分模式默认值',order: 20,view: 'text', type: 'string',},
  isLink: {title: '是否支持上下级指标分配',order: 21,view: 'text', type: 'string',},
  appMainPage: {title: '手机端主页面配置',order: 22,view: 'text', type: 'string',},
  defaultUnitName: {title: '积分模式默认值名称',order: 23,view: 'text', type: 'string',},
  defaultPlanUnit: {title: '计划分摊模式默认值',order: 24,view: 'text', type: 'string',},
  defaultPlanUnitName: {title: '计划分摊模式默认值名称',order: 25,view: 'text', type: 'string',},
  gstjzd: {title: '工时统计字段',order: 26,view: 'text', type: 'string',},
  path: {title: 'path',order: 27,view: 'text', type: 'string',},
  flag: {title: '标识（1：系统初始创建  2：其它）',order: 28,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}